package com.example.rabbitmqdemo.simple;

import com.example.rabbitmqdemo.util.ConnectionUtils;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

import java.io.IOException;
import java.util.*;
import java.util.concurrent.TimeoutException;

public class Send {
    private static final String QUEUE_NAME="test_simple_queue";
    public static void main(String[] args) throws IOException, TimeoutException {
        Connection connection = ConnectionUtils.getConnection();
        Channel channel = connection.createChannel();
        AMQP.Queue.DeclareOk queueDeclare = channel.queueDeclare(QUEUE_NAME,
                false, false, false, null);
        String msg="hello simple";
        channel.basicPublish("",QUEUE_NAME,null,msg.getBytes());
        System.out.println("--send: "+msg);
        channel.close();
        connection.close();
    }
}
